$(function(){
	//$(".cr-content").delegate(".goods-img","click",function(){
    //    $(".goods-detail-con").hide();
	//	$(this).parents(".goods-con").find(".goods-detail-con").show();
	//});
	//$(".cr-content").delegate(".glClose","click",function(){
	//	$element=$(this).parents(".goods-detail-con");
	//	$element.hide();
	//	//console.log($(this).parents(".goods-detail-con").html());
	//	//$(this).parents(".goods-detail-con").hide();
	//});
	//$(".cr-content").delegate(".glDelete","click",function(){
	//	$(this).parents(".goods-con").remove();
	//});
	$(".nav-list li").click(function(){
		$(".nav-list li").removeClass("li-active");
		$(this).addClass("li-active");

        category = $(this).attr("category");
        text = $(this).attr("text");

        $('.all-my-love').html("所有宝贝" + text);
        
        do_some_ajax(category, $("#tel").val(), $("#type").val());

	});
});

function do_some_ajax(category, tel, type){
    jQuery.ajax({
        url     : 'AppWebImageFetch',
        type    : 'POST',
        dataType: 'json',
        data    :{
            'category': category,
            'tel': tel,
            'type': type,
        },
        success : function(data){
            $('.search-num').html("共搜到" + data.length + "个宝贝");
            //alert("Success. Got the message:\n "+ data[0].path);
            uidata = "";
            for(var i=0; i < data.length; i++){
                tempData = 
                '<div class="goods-con">' 
                    + '<img class="goods-img" src="' + data[i].path + '"/>'
                    //+ '<a href="" target="_blank" class="goods-desc-a">'
                    + '<a target="_blank" class="goods-desc-a">'
                      + '<span class="goods-desc">' + data[i].name + '</span>'
                    + '</a>'
                    + '<div class="goods-detail-con">'
                      + '<div class="g-d-header">'
                        + '<img class="glDelete" src="/static/app/assets/images/icon_web_delete2.png"/>'
                        + '<span class="g-d-span-delete">删除</span>'
                        + '<img class="glModify" src="/static/app/assets/images/icon_xiugai.png"/>'
                        + '<span class="g-d-span-edit">修改</span>'
                        + '<img src="/static/app/assets/images/icon_cancle.png" class="glClose"/>'
                      + '</div>'
                      + '<div class="g-d-content">'
                        + '<div><span>尺寸：</span><span>' + data[i].size + '</span></div>'
                        + '<div><span>材质：</span><span>' + data[i].material + '</span></div>'
                        + '<div><span>重量：</span><span>' + data[i].weight + '</span></div>'
                        + '<div><span>价格：</span><span>' + data[i].price + '</span></div>'
                        + '<div><span>宝贝描述：</span><span>' + data[i].description + '</span><br/><img src="' + data[i].path + '"/></div>'
                        + '<div><span>宝贝链接：</span><span><a href="/AppWebRedirect?url=' + data[i].url + '">' + data[i].url + '</a></span></div>'
                      + '</div>'
                      + '<input class="good-md5" id="md5" name="md5" type="hidden" value="' + data[i].MD5 + '">'
                    + '</div>'
                  + '</div>';
                uidata = uidata + tempData;
            }
            $('.cr-content').html(uidata);
        }
    });
}
